<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php

	require_once("../connectMysql/connetMysql.class.php");
	session_start();
	$UserPhone=$_SESSION['mb'];
	
	$db=new connetMysql;
	$con=$db->getConnect();
	$get_idsql="SELECT UserId FROM user WHERE UserPhone='".$UserPhone."'";
	
	$result=$con->query($get_idsql);
	$row = mysqli_fetch_assoc($result);
	$Userid=$row['UserId'];
	$projectid=$_POST['projectid'];
	$uptype=$_POST['uptype'];
	$title=$_POST['title'];
	$ptime=$_POST['ptime'];
	$ptype=(int)$_POST['ptype'];
	$pstatus=(int)$_POST['pstatus'];
	$psum=(int)$_POST['psum'];
	$prov=$_POST['prov'];
	$city=$_POST['city'];
	$needrec=$_POST['needrec'];
	$pdescri=$_POST['pdescri'];
	
	$intro=$_POST['intro'];
	date_default_timezone_set('PRC');
    $ActPublishTime=date("Y-m-d h:i:s");	
	if($uptype==0)
	{
		$sql = "INSERT INTO project(Userid,ProPublish,ProStart,ProProv,ProCity,ProName,ProDescri,ProContent,ProType,ProStatus,ProLimitNum,ProNeedRec)
VALUES(".$Userid.",'".$ActPublishTime."','".$ptime."','".$prov."','".$city."','".$title."','".$pdescri."','".$intro."',".$ptype.",".$pstatus.",".$psum.",'".$needrec."')";
		
		
		$result = mysqli_query($con,$sql);
		echo "<script>alert('发布成功！');</script>";
		$con->close(); 
		echo "<script>window.location.href='project.php'</script>";
		
	}
	else
	{
		$updatesql="UPDATE project SET ProStart='".$ptime."',ProProv='".$prov."',ProCity='".$city."',ProName='".$title."',ProDescri='".$pdescri."',ProType=".$ptype.",ProStatus=".$pstatus.",ProLimitNum=".$psum.",ProNeedRec='".$needrec."',ProContent='".$intro."'
WHERE ProjectId=".$projectid;
		mysqli_query($con,$updatesql);
		echo "<script>alert('更新成功！');</script>";
		$con->close(); 
		echo "<script>window.location.href='proshow.php?projectid=".$projectid."'</script>";
	}
	
?>